package com.cong.outlets.service;

import com.cong.outlets.entity.Lens;
import com.cong.outlets.entity.OutletsLens;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author cong
 * @since 2023/10/20 14:16
 */
@Service
public class LensService {


    @Autowired
    OutletsLensService outletsLensService;

    public List<Lens> getListByOutletsId(Long outletsId) {
        // 查询关系表 获取对应的镜片id
        List<OutletsLens> outletsLens = outletsLensService.listByOutletsId(outletsId);

        //根据关系表中的id查询对应的镜片信息
        ArrayList<Lens> lens = new ArrayList<>();
        // 模拟从数据库中查询镜片信息
        outletsLens.forEach(o -> lens.add(Lens.builder().id(o.getLensId()).name("lensName:" + o.getLensId()).build()));
        return lens;

    }
}
